//
//  DGLCustomPopViewController.m
//  YUNWUMeetingDemo
//
//  Created by mac on 2019/7/15.
//  Copyright © 2019 DGL. All rights reserved.
//

#import "DGLCustomPopViewController.h"

@interface DGLCustomPopViewController ()

@end

@implementation DGLCustomPopViewController

- (void) presentationTransitionWillBegin
{
    //使用UIVisualEffectView实现模糊效果
    UIBlurEffect *blur  = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    UIVisualEffectView *visualView = [[UIVisualEffectView alloc]initWithEffect:blur];
    visualView.frame = self.containerView.bounds;
    visualView.alpha = 0.4;
    visualView.backgroundColor = [UIColor blackColor];
    [self.containerView addSubview:visualView];
    
    // 添加点击手势，点击模糊层present回上一页
    [visualView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)]];
}

- (void) containerViewWillLayoutSubviews{
    [super containerViewWillLayoutSubviews];
    CGFloat windowH = [UIScreen mainScreen].bounds.size.height;
    
    CGFloat windowW = [UIScreen mainScreen].bounds.size.width;
    
    self.presentedView.frame = CGRectMake(0, windowH - 360, windowW, 360);
    
    //    self.presentedView.backgroundColor = [UIColor clearColor];
    
}


- (void)tapAction:(UITapGestureRecognizer *)tap {
    // 判断当前是否是空白处的高度范围，是则下移弹窗，不是则不作任何处理
    if (tap.view.frame.origin.y < 345) {
        
        [self.presentedViewController dismissViewControllerAnimated:NO completion:^{
            
        }];
        
        [[NSNotificationCenter defaultCenter] postNotificationName:@"showFootView" object:nil];
    }
    
}

@end
